#!/lusr/bin/perl -w

if (scalar @ARGV < 2) {
   print "USAGE: perl run.pl {j|p|e|r} TRAIN_SIZE [seed]\n";
   die;
}

$e=$ARGV[0];
if ($e ne "j" && $e ne "p" && $e ne "e" && $e ne "r") {
   print "USAGE: perl run.pl {j|p|e|r} TRAIN_SIZE\n";
   die;
}
$train=$ARGV[1];

if ($e eq "j") {
   $str = "-joint";
}
if ($e eq "p") {
   $str = "-pipeline";
}
if ($e eq "r") {
   $str = "-relation-only";
}
if ($e eq "e") {
   $str = "-entity-only";
}
system("make");

$c="";
for ($i=0; $i<5; ++$i) {
   if (scalar @ARGV == 3) {
      $seed = $ARGV[2];
      print("./main $str -fold $i -train $train -seed $seed > out/$e$i-$train\n");
      system("./main $str -fold $i -train $train -seed $seed > out/$e$i-$train");

   }
   else {
      print("./main $str -fold $i -train $train > out/$e$i-$train\n");
      system("./main $str -fold $i -train $train > out/$e$i-$train");
   }
   $c .= " out/$e$i-$train"
}

system("cat $c > out/$e-$train");
system("perl out/eval.pl out/$e-$train > out/eval-$e-$train");
